package org.mebusw.davincicode.vo;


import org.mebusw.vo.Card;

/**
 * A card played in the Davinci Code game.<br>
 * NOTE: Be careful of the byte align problem occurred in serializing
 * @author j1shen
 * 
 */
public class DavinciCard extends Card {
	public final static boolean BLACK = true;
	public final static boolean WHITE = false;
	public final static boolean JOKER = true;
	public final static boolean NONJOKER = false;
	public final static int JOKER99 = 99;
	public final static boolean REVEALED = true;
	public final static boolean MASKED = false;
	public final static int UNKNOWN_CARDID = -1;
	public final static int PLACE_HOLDER = 100;
	public final static int NO_OWNER = -1;
	public final static int IN_POOL = 1150;


	/** 0~11, JOKER99 for joker, PLACE_HOLDER for the place holder */
	private int value;

	/** id of the player who owns this card */
	private int owner;

	/** used to identify in JSP/Flex, 0~25, PLACE_HOLDER for place holder */
	private int cardId;

	/** it's revealed or still masked */
	private boolean isRevealed;

	/** Black or white? */
	private boolean isBlack;

	/** is it a joker? */
	private boolean isJoker;
	/**
	 * 
	 * @param black
	 *            Black or White?
	 * @param value
	 *            Number of Card.
	 * @param joker
	 *            Is it a joker?
	 * @param cardId
	 *            Use to trace card uniquely.
	 * @param isRevealed
	 *            revealed or masked.
	 * @param owner
	 *            owner player.
	 */
	public DavinciCard(boolean black, int value, boolean joker, int cardId,
			boolean isRevealed, int owner) {
		this.isBlack = black;
		this.value = value;
		this.isJoker = joker;
		this.cardId = cardId;
		this.isRevealed = isRevealed;
		this.owner = owner;
	}

	public DavinciCard() {

	}

	public int getCardId() {
		return cardId;
	}

	public void setCardId(int cardId) {
		this.cardId = cardId;
	}

	public boolean isBlack() {
		return isBlack;
	}

	public void setBlack(boolean black) {
		this.isBlack = black;
	}

	public int getValue() {
		return value;
	}

	public void setValue(int value) {
		this.value = value;
		if (JOKER99 == value)
			this.isJoker = JOKER;
	}

	public boolean isJoker() {
		return isJoker;
	}

	public void setJoker(boolean joker) {
		this.isJoker = joker;
		if (isJoker)
			this.value = JOKER99;
	}

	public void setOwner(int owner) {
		this.owner = owner;
	}

	public int getOwner() {
		return owner;
	}

	public void setRevealed(boolean isRevealed) {
		this.isRevealed = isRevealed;
	}

	public boolean isRevealed() {
		return isRevealed;
	}


}
